package linkedList;

import java.util.*;


public class LinkedListTest {
    public static void main(String[] args) {
        List<String> a = new LinkedList<>();
        a.add("Amy");
        a.add("Carl");
        a.add("Erica");
        System.out.println("a is:" + a);

        List<String> b = new LinkedList<>();
        b.add("Bob");
        b.add("Doug");
        b.add("Frances");
        b.add("Gloria");
        System.out.println("b is:" + b);

        ListIterator<String> aIter = a.listIterator(1);
        Iterator<String> bIter = b.iterator();
        
        while (bIter.hasNext()) {
            if (aIter.hasNext()) aIter.next();
            aIter.add(bIter.next());
        }
        System.out.println("fisrt:" + a);

        ListIterator<String> aaIter = a.listIterator();
        Iterator<String> bbIter = b.iterator();
        while (bbIter.hasNext()) {
            if (aaIter.hasNext()) aaIter.next();
            aaIter.add(bbIter.next());
        }
        System.out.println("second:" + a);

        bIter = b.iterator();
        while (bIter.hasNext()) {
            bIter.next();
            if (bIter.hasNext()) {
                bIter.next();
                bIter.remove();
            }
        }

        System.out.println(b);

        a.removeAll(b);
        System.out.println(a);
    }
}
